import matplotlib.pyplot as plt
import numpy as np

# 数据
years = np.array([2021, 2022, 2023])
catl_revenue = np.array([1303.56, 3285.94, 4009.17])  # 宁德时代营业收入
catl_net_profit = np.array([159.31, 307.29, 441.21])  # 宁德时代净利润
catl_total_assets = np.array([3076.67, 6009.52, 7171.68])  # 宁德时代资产总额
tp_revenue = np.array([91.60, 159.93, 219.06])  # 拓普集团营业收入
tp_net_profit = np.array([8.56, 13.48, 22.56])  # 拓普集团净利润
tp_total_assets = np.array([109.95, 171.30, 230.95])  # 拓普集团资产总额

# 图表设置
plt.rcParams['font.family'] = 'SimHei'  # 设置中文字体为黑体
plt.rcParams['axes.unicode_minus'] = False  # 解决负号显示问题

# 绘制营业收入对比图
plt.figure(figsize=(10, 6))
plt.plot(years, catl_revenue, label='CATL Revenue', marker='o')
plt.plot(years, tp_revenue, label='TP Revenue', marker='s')
plt.xlabel('Year')
plt.ylabel('Revenue (Billion Yuan)')
plt.title('Comparison of Revenue between CATL and TP')
plt.legend()
plt.show()

# 绘制净利润对比图
plt.figure(figsize=(10, 6))
plt.plot(years, catl_net_profit, label='CATL Net Profit', marker='o')
plt.plot(years, tp_net_profit, label='TP Net Profit', marker='s')
plt.xlabel('Year')
plt.ylabel('Net Profit (Billion Yuan)')
plt.title('Comparison of Net Profit between CATL and TP')
plt.legend()
plt.show()

# 绘制资产总额对比图
plt.figure(figsize=(10, 6))
plt.plot(years, catl_total_assets, label='CATL Total Assets', marker='o')
plt.plot(years, tp_total_assets, label='TP Total Assets', marker='s')
plt.xlabel('Year')
plt.ylabel('Total Assets (Billion Yuan)')
plt.title('Comparison of Total Assets between CATL and TP')
plt.legend()
plt.show()